<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Todo注册</title>
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.min.css">
<script type="text/javascript" src="bootstrap-3.3.7-dist/js/jquery.min.js"></script>
<script type="text/javascript" src="bootstrap-3.3.7-dist/js/bootstrap.js"></script>
<script type="text/javascript" src="jQuery/jquery-3.1.1.js"></script>
<script type="text/javascript">
	
	function checkRegister(){
		if(("恭喜，该手机号可用来注册"==$("#phoneErr").html()) && ("恭喜，该用户名可以注册"==$("#usernameErr").html())){
			alert($("#phoneErr").html()+"对了11！！！！");
			alert($("#usernameErr").html());
			return true;
		}else{
			alert($("#phoneErr").html()=="恭喜,此手机号可用来注册");
			alert("恭喜，该用户名可以注册"==$("#usernameErr").html());
			return false;
		}
	}
	
	$(function(){
		$("#username").blur(function(){
			$.ajax({
				url:"/20180519SpringmvcTodo/usernameErr.do",
				data:{"username":$("#username").val()},
				method:"get",
				success:function(data){
					$("#usernameErr").html(data);
				}
			});
		});
		
		$("#phonenumber").blur(function(){
			$.ajax({
				url:"/20180519SpringmvcTodo/phoneErr.do",
				data:{"phonenumber":$("#phonenumber").val()},
				method:"get",
				success:function(data){
					$("#phoneErr").html(data);
				}
			});
		});
	});
	
</script>
</head>
<body>
	
	<div class="container">
		<form action="${pageContext.servletContext.contextPath }/register.do" method="post" onsubmit="return checkRegister()">
			<div class="col-md-offset-4 col-md-4">
				<div class="page-header">
					TODO注册
				</div>
			</div>
			<div class="col-md-offset-4 col-md-4">
				<div class="form-group form-group-sm">
					<label for="username">请输入注册用户名：</label>
					<input id="username" type="text" class="form-control" name="username" placeholder="请输入注册用户名">
					<span id="usernameErr" style="color:red"></span>
					</br></br>
					<label for="password">请输入注册密码：</label>
					<input id="password" type="password" class="form-control" name="password" placeholder="请输入注册密码"></br></br>
					<label for="phonenumber">请输入手机号：</label>
					<input id="phonenumber" type="text" class="form-control" name="phonenumber" placeholder="请输入您的手机号">
					<span id="phoneErr" style="color:red"></span>
					</br></br>
					<button type="submit" class="btn btn-default btn-info">注册</button>
				</div>
			</div>
		</form>
	</div>
</body>
</html>